{% extends 'task/_task.html' %}
{% block ac_done %} active actmore {% endblock %}

{% block head %}
{{ super() }}
<link type="text/css" rel="stylesheet" href="{{ url_for('static', filename='css/style2.css') }}">
{% endblock head %}


<!-- 1 下拉列表-排序选择 -->
{% block top_bar %}
<!-- 弃用：平常都没用上过 -->
<li class="nav-item dropdown" style="display: none;">
    {% set orders = {
        TaskOrder.FD:'完成时间 ↑', TaskOrder.FA:'完成时间 ↓',
        TaskOrder.AD:'创建时间 ↑', TaskOrder.AA:'创建时间 ↓',
        TaskOrder.ND:'任务名称 ↑', TaskOrder.NA:'任务名称 ↓'} %}

    <a class="nav-link dropdown-toggle" role="button" href="#" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true"
        aria-expanded="false">
        {{ orders[order_id] }}
    </a>
    <div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
        {% for order_id in orders %}
        <a class="dropdown-item" href="{{ url_for('.task_done', order_id=order_id, keyword=request.args.get('keyword')) }}">
            {{ orders[order_id] }}
        </a>
        {% endfor %}
    </div>
</li>
{% endblock %}

<!-- 2 搜索框-默认get请求 -->
{% block top_bar_nav %}
<form class="form-inline">
    <input name="keyword" class="form-control mr-sm-2" type="search" placeholder="关键词" aria-label="Search">
    <button class="btn btn-outline-success my-2 my-sm-0" type="submit">搜索</button>
</form>
{% endblock top_bar_nav %}

<!-- 3 完成任务列表 -->
{% block show %}
<table class="table table-striped">
    <thead>
        <tr>
            <th scope="col">N</th>
            <th scope="col">任务名</th>
            <th scope="col">完成时间</th>
            <th scope="col">耗时</th>
            <th scope="col">完成描述</th>
            <th scope="col">操作</th>
        </tr>
    </thead>
    <tbody>
        {% for task in tasks if task['is_finish'] %} <!-- 备注：在后端筛选已完成的？ -->
        <tr>
            <th scope="row">{{ task['id'] }}</th>
            <td class="name">{{ task['name'] }}</td>
            <td>{{ task['time_finish'] }}</td>
            <td>{{ task['hour'] }}h</td>
            <td class="describe">{{ task['describe'] }}</td>
            <td>
                <a class="btn btn-success btn-sm"
                    href="{{ url_for('.task_submit', task_id=task['id'], next=request.endpoint) }}" role="button">修改</a>
            </td>
        </tr>
        {% endfor %}
    </tbody>
</table>
{% endblock %}
